package dc.utils;

import java.util.ArrayList;
import java.util.List;

import bbb.sss.Utils;
import dc.DCB;
import dc.HistoryData;
import dc.Outcome;
import distribution.DistributionScheme;
import distribution.SchemeItem;

public class DCBUtils {

	public static DCB randomDCB(int redMax, int redCount, int blueMax,
			int blueCount) {
		long redCode = (long) (Math.random() * Utils.c(redMax, redCount)) + 1;
		long blueCode = (long) (Math.random() * Utils.c(blueMax, blueCount)) + 1;
		SchemeItem red = DistributionScheme.parse(redMax, redCount, redCode);
		SchemeItem blue = DistributionScheme
				.parse(blueMax, blueCount, blueCode);
		DCB dcb = new DCB(red, blue, 0);
		return dcb;
	}

	public static DCB randomDCB() {
		return randomDCB(33, 6, 16, 1);
	}

	public static List<Integer> randomCodes(int max, int count) {
		long code = (long) (Math.random() * Utils.c(max, count)) + 1;
		SchemeItem codes = DistributionScheme.parse(max, count, code);
		return codes.getCodes();
	}

	public static DCB createDCB(List<Integer> redCodes,
			List<Integer> blueCodes, int multipe) {
		SchemeItem red = new SchemeItem(redCodes);
		SchemeItem blue = new SchemeItem(blueCodes);
		DCB dcb = new DCB(red, blue, multipe);
		return dcb;
	}

	public static HistoryData createHistory(int count){
		HistoryData hd = new HistoryData();
		hd.setHo(new ArrayList<Outcome>());
		for(int i = 1 ; i < count; i++){
			Outcome co = new Outcome();
			co.setNumber(i);
			co.setCurrent(DCBUtils.randomDCB());
			co.compute();
			hd.getHo().add(co);
		}
		return hd;
	}
	
	public static void main(String[] args) {

	}
}
